//
//  KDBlackListViewController.m
//  LaiKeDaoClient
//
//  Created by dongkedi的iMac on 15/11/9.
//  Copyright © 2015年 LKD. All rights reserved.
//

#import "KDBlackListViewController.h"
#import "KDBlackListTableViewCell.h"

@interface KDBlackListViewController ()<UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate>
{
    UITableView     *_tableView;
    UITextField     *_textField;
}


@end

@implementation KDBlackListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view setBackgroundColor:[UIColor colorWithHexString:@"0xF2F2F2"]];
    [self setNaviLeftButton];
    [self setNaviTitle:@"黑名单"];
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:(CGRect){0,0,kScreenWidth,22}];
    [titleLabel setBackgroundColor:[UIColor colorWithHexString:@"#666666"]];
    [titleLabel setTextColor:[UIColor whiteColor]];
    [titleLabel setText:@"加入黑名单的患者将无法再次关注您"];
    [titleLabel setTextAlignment:NSTextAlignmentCenter];
    [self.view addSubview:titleLabel];
    
    _textField = [[UITextField alloc] initWithFrame:(CGRect){9,22+9,kScreenWidth-18,30}];
    [_textField setBorderStyle:UITextBorderStyleRoundedRect];
    [_textField setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
    [_textField setPlaceholder:@"        输入姓名、手机号查找患者"];
    [self.view addSubview:_textField];
    _textField.delegate = self;
    
    _tableView = [[UITableView alloc] initWithFrame:(CGRect){0,Y(_textField)+HEIGHT(_textField)+9,kScreenWidth,HEIGHT(self.view)-HEIGHT(titleLabel)-HEIGHT(_textField)-18} style:UITableViewStylePlain];
    _tableView.dataSource = self;
    _tableView.delegate   = self;
    _tableView.backgroundColor = [UIColor colorWithHexString:@"0xF2F2F2"];
    [_tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    [self.view addSubview:_tableView];
}
- (void)viewWillAppear:(BOOL)animated
{
    SharedAppDelegate.tabBarController.tabBarIsHiden = YES;
    [self requestGetBlackList];
}

- (void)viewWillDisappear:(BOOL)animated
{
    SharedAppDelegate.tabBarController.tabBarIsHiden = NO;
}

//网络交互
//getBlackList
-(void)requestGetBlackList
{
    [CSHApiClient getBlackListDidFinishLoaded:^(KXJson *json, NSString *path) {
        //
        
    } didFailLoaded:^(NSError *error, NSString *path) {
        //
    }];
}
//rmBlackList
-(void)requestRMBlackListPatient_token:(NSString *)Patient_token
{
    [CSHApiClient rmBlackListPatient_token:Patient_token DidFinishLoaded:^(KXJson *json, NSString *path) {
        //
        
    } didFailLoaded:^(NSError *error, NSString *path) {
        //
    }];
}

- (void)hidenKey
{
    [_textField resignFirstResponder];
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [self hidenKey];
    return YES;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 1;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
{
    return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 55;
}
- (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(6_0)
{
    return NO;
}
//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    [tableView deselectRowAtIndexPath:indexPath animated:YES];
//}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *CustomCellIdentifier = [NSString stringWithFormat:@"CellIdentifier%ld",(long)indexPath.row+indexPath.section*10];
    KDBlackListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CustomCellIdentifier];
    if (cell ==nil) {
        cell = [[KDBlackListTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CustomCellIdentifier];
        
        UIView  *line = [[UIView alloc] initWithFrame:(CGRect){0,54,WIDTH(cell.contentView),1}];
        [line setBackgroundColor:[UIColor colorWithHexString:@"0xF2F2F2"]];
        [cell.contentView addSubview:line];
    }
    
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
